package com.wx.chapter17.method;

/**
 * @Author : 佩萁
 * Description :
 * @Create : 2023/8/18 - 11:10
 */
public class ThreadMethodExercise2 {
    public static void main(String[] args) throws InterruptedException {
        MyDaemonThread myDaemonThread = new MyDaemonThread();
        myDaemonThread.setDaemon(true);//设置为守护线程
        myDaemonThread.start();
        for (int i = 1; i <= 100; i++) {//主线程循环
            Thread.sleep(50);
            System.out.println("宝强辛苦工作~~~~~~~~~~~~~~" + i);
        }
    }
}

class MyDaemonThread extends Thread {
    @Override
    public void run() {
        for (; ; ) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("马蓉和宋喆快乐聊天，哈哈哈~~~");
        }
    }
}